package net.qhzw.vip.qiyu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import net.qhzw.vip.qiyu.entity.DtsUser;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.result.PageResult;
import net.qhzw.vip.qiyu.service.DtsUserService;
import net.qhzw.vip.qiyu.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户管理
 *
 * @title: DtsUserCcontroller
 * @Author zhang
 * @Date: 2022/7/6 15:48
 * @Version 1.0
 */
@RestController
@RequestMapping("dts/user")
@Api(tags = "用户管理")
public class DtsUserController {


    @Autowired
    private DtsUserService dtsUserService;


    @GetMapping
    public List<DtsUser> getDtsUser(@RequestParam Long communityId) {
        List<DtsUser> dtsUserList = dtsUserService.getDtsUser(communityId);
        return dtsUserList;
    }

    @GetMapping("/{id}")
    public DtsUser getDtsUserById(@PathVariable Long id) {
        DtsUser dtsUser = dtsUserService.getById(id);
        return dtsUser;
    }

    /**
     * 租车用户信息
     *
     * @param page
     * @param realName
     * @param mobile
     * @param idCard
     * @return
     */
    @GetMapping("car/rental")
    public JsonResult<PageResult<DtsUser>> findCarRental(Page<DtsUser> page, String realName, String mobile, String idCard) {
        Long shopId = SecurityUtils.getLoginUser().getShopId();
        PageResult<DtsUser> pageResult = dtsUserService.findCarRental(page, shopId, realName, mobile, idCard);
        return JsonResult.ok(pageResult);
    }

    /**
     * 商城用户
     *
     * @param page
     * @param name
     * @return
     */
    @GetMapping("mall")
    public JsonResult<PageResult<DtsUser>> findMall(Page<DtsUser> page, String name, Byte isVip) {
        PageResult<DtsUser> pageResult = dtsUserService.findMall(page, name, isVip);
        return JsonResult.ok(pageResult);
    }


}
